insurance_sumstats_table <- function(){
  
  table <- read.csv("../release/paper_sumstats/tables/sum_stats/insurer_spending.csv")
  rownames <- c("\\quad Overall",
                        "\\quad Bronze plans",
                        "\\quad Silver plans",
                        "\\quad Gold plans",
                        "\\quad Overall",
                        "\\quad Bronze plans",
                        "\\quad Silver plans",
                        "\\quad Gold plans", 
                        "\\quad Overall",
                        "\\quad Bronze plans",
                        "\\quad Silver plans",
                        "\\quad Gold plans", 
                        "\\quad Bronze plans",
                        "\\quad Silver plans",
                        "\\quad Gold plans")
                        
  counts <- read.csv("../release/paper_sumstats/tables/sum_stats/count_insurance.csv")
  count_mat <- cbind(counts[3:4, 2], c(NA, NA), c(NA, NA), counts[3:4, 3], c(NA, NA), c(NA, NA))
  row.names(count_mat) <- c("\\quad unique HHs",
                            "\\quad HH-year observations")
  
  MakeLatexTableAdj(
    startcodelist = list(
      "\\begin{table}[H]",
      "\\begin{centering}",
      "\\begin{tabular}{lcccccc}",
      "&  &  &  &  &  & \\tabularnewline",
      "\\hline", 
      "\\hline", 
      "& \\multicolumn{3}{c}{\\textbf{Individual market}} & \\multicolumn{3}{c}{\\textbf{Small group Market}}\\tabularnewline",
      "\\cline{2-7} \\cline{3-7} \\cline{4-7} \\cline{5-7} \\cline{6-7} \\cline{7-7}", 
      "\\textbf{Variable} & \\textbf{Mean} & \\textbf{S.D.} & \\textbf{Median} & \\textbf{Mean} & \\textbf{S.D.} & \\textbf{Median}\\tabularnewline",
      "\\hline", 
      "Spending = 0 & & & & & & \\tabularnewline"), 
    tableinnardslist = list(
      table[1:4, -1], 
      100 * table[5:8, -1], 
      100 * table[9:12, -1], 
      table[13:15, -1], 
      cbind(c(7.0, 6.5), c(NA, NA), c(NA, NA), c(8.0, 7.3), c(NA, NA), c(NA, NA)),
      count_mat), 
    rownames = list(
      rownames[1:4], 
      rownames[5:8], 
      rownames[9:12], 
      rownames[13:15], 
      c("\\multicolumn{1}{r}{in rating areas 1-3 (mean)}", "\\multicolumn{1}{r}{in rating areas 4-7 (mean)}"), 
      row.names(count_mat)),
    tableinnardsroundvec = c(2, 0, 0, 2, 1, 0), 
    inbetweencodelistlist = list(
      list("\\hline", 
           "HH spending (if nonzero) & & & & & & \\tabularnewline"), 
      list("\\hline",
           "Monthly HH premiums & & & & & & \\tabularnewline"),
      list("\\hline", 
           "Market shares & & & & & & \\tabularnewline"),
      list("\\hline", 
           "Number of insurers active & & & & & & \\tabularnewline"),
      list("\\hline", 
           "Number of & & & & & & \\tabularnewline")
      ),
    endcodelist = list(
      "\\hline",
      "\\hline",
      "\\end{tabular}",
      "\\par\\end{centering}",
      "\\caption{Summary statistics on insurance variables} \\label{tab:main_t_sum_stats_insurance}",
      "\\end{table}")
  )
}
